import java.util.Scanner;

public class Day_18_2_字符串通配符 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            String s1 = scan.nextLine();
            String s2 = scan.nextLine();
            System.out.println(isTrue(s1, s2));
        }
    }
    public static boolean isTrue(String s1, String s2) {
        if(s1.length() > s2.length()) {
            return false;
        }
        int i = 0;
        int j = 0;
        while(i < s1.length() && j < s2.length()) {
            if(s1.charAt(i) != '*' && s1.charAt(i) != '?') {
                if(s1.charAt(i) != s2.charAt(j)) {
                    return false;
                }else {
                    i++;
                    j++;
                }
            }else if(s1.charAt(i) == '*' && i != s1.length() - 1) {
                if(s1.length() == s2.length()) {
                    i++;
                    j++;
                }else {
                    i++;
                    while(j < s2.length()) {
                        if(s1.charAt(i) == s2.charAt(j)) {
                            break;
                        }else {
                            j++;
                        }
                    }
                }
            }else if(s1.charAt(i) == '?') {
                i++;
                j++;
            }else if(s1.charAt(i) == '*' && i == s1.length() - 1) {
                return true;
            }
        }
        if(i == s1.length()) {
            return true;
        }
        return false;
    }
}
